/* M Orsi - Essex group - Soton univ, 2005-2008 */

#include "definitions.h"

enum { PM = 0, SRB = 1, NSRB = 3 }; /* mechanical type: Point Mass, Symmetric Rigid Body, Non-Symmetric Rigid Body */
enum { WAT = 0, CHOL = 1, PHOS = 2, GLY = 3, TAIL = 4, SOLUTE = 5 }; /* chemical type  */
enum { OO = 0, OH = 1, HH = 2 }; // for water rdf computation
enum { NON_LIPID = 0, DMPC = 1, DOPC = 2, DOPE = 3 }; // lipSpecies

// lipUnit 
enum { WATER=0, CHOLINE=1, PHOSPHATE=2, GLYCEROL_A=3, TAIL_A1=4, TAIL_A2=5, TAIL_A3=6, GLYCEROL_B=7, TAIL_B1=8, TAIL_B2=9, TAIL_B3=10 , TAIL_A4=11, TAIL_B4=12, SOL=999}; 

/* DMPC TOPOLOGY: */

/*       CHOLINE     1 */
/*          | */
/*       PHOSPHATE   2 */
/*          | */
/*       GLYCEROL_A  3 */
/*       |      |   */
/*  TAIL_A1 4   GLYCEROL_B 7 */
/*      |           | */
/*  TAIL_A2 5     TAIL_B1  8 */
/*      |           | */
/*  TAIL_A3 6     TAIL_B2  9 */
/*                  | */
/*                TAIL_B3  10 */

/* DOPC TOPOLOGY: */

/*       CHOLINE     1 */
/*          | */
/*       PHOSPHATE   2 */
/*          | */
/*       GLYCEROL_A  3 */
/*       |      |   */
/*  TAIL_A1 4   GLYCEROL_B 7 */
/*      |           | */
/*  TAIL_A2 5     TAIL_B1  8 */
/*      |           | */
/*  TAIL_A3 6     TAIL_B2  9 */
/*      |           | */
/*  TAIL_A4 11    TAIL_B3  10 */
/*                  |         */
/*                TAIL_B4  12 */

/* The main data structure is an array made of nSites item Site: */
typedef struct {   /* variables associated with each atom or site */
  VecR r, // site coordinates
    v,  // site mass-centre vels
    f,  /* force  */
    g, /*  torques in the space-fixed frame */
    e, /* unit orientation vector, GB axes and SSD dipoles */
    u;  //i)  GB sites: de/dt.  ii) SSD sites: angular momentum in the body-fixed frame. 
  RMat qMat; /* rotation matrix */
  int chemType; /* chemical types: 0 for water, 1 for choline, 2 for phosphate, 3 for glycerol, 4 for tail */
  int mechType; /* mechanical types: 0 for point-masses, 1 for symmetric rigid-bodies, 3 for non-symmetric rigid-bodies */
  int lipId; // lipid identifier: 0 if site don't belong to any lipid (eg water), 1 if it belongs to lipid-1, N if it belongs to lipid-N...
             // This will be used to skip intra-lipid nearest-neighbour nonbonded pair interactions
  int lipSpecies; // 0 for non-lipid, 1 for DMPC etc (see corresponding enum definition above at the top of the file)
  int lipUnit; /* 0 for non-lipid (water), 1 for choline, 2 for phosphate, 3-4 for glycerol backbone, 5-10 for tails */
} Site;

// DO I USE THIS STUFF? NO - GET RID? Yes 14-10-06
// rOld,  /* site coordinates - rOld auxiliary variable used in the Nose'-Hoover scheme */
// vOld,  // site linear vel
// uOld;  /* i)  GB sites: de/dt.  ii) SSD sites: angular momentum in the body-fixed frame. */
// Quat q; /* quaternion only for SSD molecules and quaternion-based integration */
/*   real sig, /\* LJ diameter sigma *\/ */
/*     eps, /\* LJ energy epsilon *\/ */
/*     mass, /\* site mass *\/ */
/*     charge; /\* site charge *\/ */

typedef struct {
  int nBeads;  
} LipidStruct;

/* Structure to contain infos for the atomistic solute in z-constrain calculations: */
typedef struct {   /* variables associated with each atom */
  char type[ 5 ]; // five elements: id (first four) + \0 (last)
  VecR r, // atom coordinates in the body-frame
    f;  /* force  */
  real charge, /* atom charge */
    sig, /* LJ diameter sigma */
    eps; /* LJ energy epsilon */
} Atom;

// Structure for the characterisation of the orientation of the AL solute(s)
typedef struct {
  Prop p2x, p2y, p2z;
} OrdParSolute;


typedef struct {
  real choline_phosphate,
    phosphate_glycerol,
    tail_tail;
} EqBondLengths;

/* TBuf: structure associated with each set of diffusion measurement (diffusion buffer) */
typedef struct {
  VecR *orgR,       /* origins for the set of measurements */
    *rTrue;         /* true displacement components (after removing  PBC effect) */
  real *rrDiffuse;  /* mean-square displacement accumulator */
  int count;        /* counter */
} TBuf;

/* latDiffBuff: structure associated with each set of lateral diffusion measurement (lateral diffusion buffer) */
typedef struct {
  VecRTwo *orgTwo,       /* origins for the set of measurements */
    *latDispTrueTwo;         /* true displacement components (after removing  PBC effect) */
  real *latSqrDisp;  /* mean-square displacement accumulator */
  int count;        /* counter */
} LatDiffBuff;

typedef struct {
  VecR r;
} WatSite;

enum errCodes {ERR_NONE, ERR_BOND_SNAPPED, ERR_CHECKPT_READ, ERR_CHECKPT_WRITE,
	       ERR_COPY_BUFF_FULL, ERR_EMPTY_EVPOOL, ERR_MSG_BUFF_FULL,
	       ERR_OUTSIDE_REGION, ERR_SNAP_READ, ERR_SNAP_WRITE,
	       ERR_SUBDIV_UNFIN, ERR_TOO_MANY_CELLS, ERR_TOO_MANY_COPIES,
	       ERR_TOO_MANY_LAYERS, ERR_TOO_MANY_LEVELS, ERR_TOO_MANY_SITES,
	       ERR_TOO_MANY_MOVES, ERR_TOO_MANY_NEBRS, ERR_TOO_MANY_REPLICAS};


